<script setup>
import HomePannel from './HomePannel.vue';
import { getHomeHotAPI } from '@/api/home'
import { ref } from 'vue';

const hotList = ref([])

const getHotList= async () => {
  const res = await getHomeHotAPI()
  hotList.value = res
}

getHotList()

</script>

<template>
<div class="homehot">
  <div class="container">
    <home-pannel title="人气推荐" desc="人气爆款 不容错过">
      <ul class="goodslist">
        <li v-for="item in hotList" :key="item.id">
          <router-link :to="`/detail/${item.id}`">
            <img :src="`${item.picture}`" alt="">
            <p class="title">{{ item.title }}</p>
            <p class="alt">{{ item.alt }}</p>
          </router-link>
        </li>
      </ul>
    </home-pannel>
  </div>
</div>
</template>

<style lang="less" scoped>
.homehot {
  background-color: #fff;
  .btn {
    float: right;
    font-size: 16px;
    color: #a1a1a1;
    i {
      margin-left: 5px;
    }
  }
  .goodslist {
    margin-top: 40px;
    width: 100%;
    display: flex;
    justify-content: space-between;
    li {
      width: 306px;
      margin-left: 5px;
      &:nth-child(1) {
        margin-left: 0;
      }
      a {
        display: block;
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
        img {
          width: 100%;
        }
        p {
          width: 100%;
          padding: 10px;
        }
        .title {
          font-size: 20px;
        }
        .alt {
          font-size: 16px;
          color: #a1a1a1;
        }
      }
      &:hover {
        transform: translateY(-3px);
        box-shadow: 0 0 10px rgba(0, 0, 0, .3);
        transition: all .5s;
      }
    }
  }
}
</style>